﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once

#include <string>
#include "GcmpModelInterface.h"
#include "IDbObject.h"

namespace gcmp
{
    class IElement;
    class IModelView;
    
    // element不可见的原因
    enum class ElementInvisibleReason : int32_t
    {
        Exception = 0,                          // 程序执行异常导致的不可见
        ElementStatus = 1,                      // 元素基础状态模块的不可见
        ElementVisibilityFilterOfDocument = 2,  // 文档级可见性过滤器过滤
        ElementVisibilityFilterOfView = 3,      // 视图中可见性过滤器过滤
        ElementViewSpecificShapeComponent = 4,  // element自定义的在某个视图中不可见
        ElementCategoryUidInvalid = 5,          // element的类别无效
        ElementVisibilityInViewByElementId = 6, // element在当前视图中被重载为不可见
        CategoryVisibilityOfDocument = 7,       // 该类别的element在文档级别被设置为不可见
        CategoryVisibilityOfView = 8,           // 该类别的element在当前视图被重载为不可见
        CategoryLackOfGraphicsStyle = 9         // 样式中没有该类别
    };

    /// \brief Element最终可见性控制器
    class GCMP_MODEL_INTERFACE_EXPORT IElementVisibilityController : public IDbObject
    {
        DEFINE_CAST_DERIVED(gcmp::IElementVisibilityController, gcmp::IDbObject)

    public:

        /// \brief 确定Element最终的可见性，忽略任何其他针对Element的可见性设置
        /// \param pModelView Element所在视图
        /// \param pElement 需要确定可见性的Element
        /// \param isNowVisible 此接口被触发时Element是否可见
        /// \param ElementInvisibleReason 此接口被触发时，如果Element不可见，原因是什么
        /// \return true-置Element为可见，false-置Element为不可见
        virtual bool IsElementVisible(const IModelView* pModelView, const IElement* pElement, bool isNowVisible, ElementInvisibleReason invisibleReason) const = 0;
    };
}


